package com.zodiac.app.datathinking.szse;

import org.springframework.util.ReflectionUtils;

import java.io.PrintWriter;
import java.io.StringWriter;

public abstract class Utils {
    /**
     * 获取异常的堆栈信息
     *
     * @param e
     * @return
     */
    public static String getExceptionStackTrace(Exception e) {
        StringWriter out = new StringWriter();
        PrintWriter pw = new PrintWriter(out);
        try {
            e.printStackTrace(pw);
            return out.toString();
        } catch (Exception ex) {
            ReflectionUtils.rethrowRuntimeException(ex);
        } finally {
            pw.close();
        }
        return null;
    }
}
